package com.gitee.jjnnzb.designpatterninspring.common.bean;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serial;

/**
 * @author Administrator
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CommonException extends RuntimeException {
    @Serial
    private static final long serialVersionUID = -4113337980199548152L;
    
    private String message;
    
    private int code = ErrorEnum.SERVER_ERROR.getErrorCode();
    
    public CommonException(String message) {
        super(message);
        this.message = message;
    }
    
    public CommonException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }
    
    
    public CommonException(ErrorEnum errorEnum) {
        super(errorEnum.getErrorMsg());
        this.message = errorEnum.getErrorMsg();
        this.code = errorEnum.getErrorCode();
    }
    
    public CommonException(int code, String message) {
        super(message);
        this.message = message;
        this.code = code;
    }
    
    public CommonException(int code, String message, Throwable cause) {
        super(message, cause);
        this.message = message;
        this.code = code;
    }
}
